package assignmentOne.thoughtworks;

/**
 * Created by derekgliwa on 6/15/14.
 */
public class PreworkDiamond {

    public static void main(String[]args){
        printCenteredTriangle(3);
        printCenteredDiamond(3);
        printCenteredDiamondWithName(3);
    }
    public static void printCenteredTriangle(int n){
        int i=0,j,k;
        for(k=1;k<=n;k++)
        {
            for(i=0;i<=n-k;i++)
            {
                System.out.print(" ");
            }
            for(j=1;j<=k;j++)
            {
                System.out.print("*");
            }
            for(j=1;j<=k-1;j++)
            {
                System.out.print("*");
            }
            System.out.println("");
        }

    }

    public static void printCenteredDiamond(int n){
        int i=0,j,k;
        for(k=1;k<=n;k++)
        {
            for(i=0;i<=n-k;i++)
            {
                System.out.print(" ");
            }
            for(j=1;j<=k;j++)
            {
                System.out.print("*");
            }
            for(j=1;j<=k-1;j++)
            {
                System.out.print("*");
            }
            System.out.println("");
        }
        for(k=1;k<=n;k++)
        {
            for(i=0;i<=k;i++)
            {
                System.out.print(" ");
            }
            for(i=1;i<=n-k;i++)
            {
                System.out.print("*");
            }
            for(j=0;j<=n-k-2;j++)
            {
                System.out.print("*");
            }
            System.out.print("\n");
        }
    }

    public static void printCenteredDiamondWithName(int n){
        int i=0,j,k;
        for(k=1;k<n;k++)
        {
            for(i=0;i<=n-k;i++)
            {
                System.out.print(" ");
            }
            for(j=1;j<=k;j++)
            {
                System.out.print("*");
            }
            for(j=1;j<=k-1;j++)
            {
                System.out.print("*");
            }
            System.out.println("");
        }
        System.out.println("Derek");
        for(k=1;k<=n;k++)
        {
            for(i=0;i<=k;i++)
            {
                System.out.print(" ");
            }
            for(i=1;i<=n-k;i++)
            {
                System.out.print("*");
            }
            for(j=0;j<=n-k-2;j++)
            {
                System.out.print("*");
            }
            System.out.print("\n");
        }
    }

}


